import { LoopFunc, MAP } from "../../Types";
import { TILE } from "../../enum";
type RenderCallback = (map: MAP, x: number, y: number) => void;

/** 这是只有在二维竖直的游戏才有的地面 */
const renderGround =
    (callback: RenderCallback): LoopFunc =>
    (map, MapGenerator) => {
        map.$forEach((value, x, y) => {
            if (value === TILE.Wall) {
                const Value = map.get(x, y - 1);
                if (Value !== undefined && Value !== TILE.Wall) {
                    callback(map, x, y);
                }
            }
        });
        return map;
    };
export { renderGround };
